Skip to content

Allow SegmentedControl labels to wrap without overflow - #8442

Open
joshfarrant wants to merge 12 commits into
mainfrom
joshfarrant-fix-segmented-control-wrapping
Open

joshfarrant wants to merge 12 commits into
mainfrom
joshfarrant-fix-segmented-control-wrapping

Conversation

@joshfarrant

@joshfarrant joshfarrant commented Sep 22, 2026

Copy link
Copy Markdown
Contributor

Closes github/primer#7156

SegmentedControl previously fixed its track to 32px, or 28px at the small size, which allowed multiline labels to escape the track and selected-state treatment. This PR updates the fixed height to min-height so the control grows to its tallest segment.

Changelog

New

  • Add deterministic multiline Storybook coverage for selected and unselected labels across default and subtle variants, both sizes, icons, counters, and unchanged single-line references.
  • Add Playwright geometry and accessibility stress coverage for equal segment heights, selected-content sizing, 320px reflow, enlarged text, and WCAG text spacing.
  • Add an @primer/react patch changeset.

Changed

  • Preserve the existing 32px and 28px control dimensions as minimum heights, allowing SegmentedControl to grow vertically with wrapped labels.

Removed

  • None.

Rollout strategy

  • Patch release
  • Minor release
  • Major release; if selected, include a written rollout or migration plan
  • None; if selected, include a brief description as to why

Testing & Reviewing

Primer React tests pass, and compatibility also verified in github-ui.

@changeset-bot

changeset-bot Bot commented Sep 22, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: d7bfaa1

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@primer/react Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions github-actions Bot added the integration-tests: recommended This change needs to be tested for breaking changes. See https://arc.net/l/quote/tdmpakpm label Sep 22, 2026
@github-actions

Copy link
Copy Markdown
Contributor

⚠️ Action required

👋 Hi, this pull request contains changes to the source code that github/github-ui depends on. If you are GitHub staff, test these changes with github/github-ui using the integration workflow. Check the integration testing docs for step-by-step instructions. Or, apply the integration-tests: skipped manually label to skip these checks.

@github-actions
github-actions Bot temporarily deployed to storybook-preview-8442 September 22, 2026 10:25 Inactive
@joshfarrant joshfarrant added the update snapshots 🤖 Command that updates VRT snapshots on the pull request label Sep 22, 2026
@github-actions github-actions Bot removed the update snapshots 🤖 Command that updates VRT snapshots on the pull request label Sep 22, 2026
@joshfarrant
joshfarrant requested a balanced review from Copilot September 22, 2026 13:46
@github-actions
github-actions Bot temporarily deployed to storybook-preview-8442 September 22, 2026 13:48 Inactive

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

The enlarged-text test can pass despite horizontal overflow because it samples page overflow too early and only checks content height.

Get a fresh assessment by requesting another Copilot review.

Review effort: Balanced
Findings: 1 Medium severity

Open (1)
What changed in this PR

Updates SegmentedControl to grow vertically for wrapped labels while preserving standard minimum heights.

Changes:

  • Replaces fixed heights with minimum heights.
  • Adds multiline Storybook and Playwright coverage.
  • Adds an @primer/react patch changeset.
File Description
SegmentedControl.module.css Allows vertical growth.
SegmentedControl.features.stories.tsx Adds wrapping scenarios.
SegmentedControl.features.stories.module.css Styles test scenarios.
SegmentedControl.test.ts Adds layout and reflow tests.
.changeset/​segmented-control-wrap-labels.md Documents the patch.

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

Comment thread e2e/components/SegmentedControl.test.ts Outdated
@github-actions github-actions Bot added integration-tests: failing Changes in this PR cause breaking changes in gh/gh and removed integration-tests: recommended This change needs to be tested for breaking changes. See https://arc.net/l/quote/tdmpakpm labels Sep 22, 2026
@github-actions
github-actions Bot temporarily deployed to storybook-preview-8442 September 22, 2026 15:37 Inactive
@joshfarrant joshfarrant added the update snapshots 🤖 Command that updates VRT snapshots on the pull request label Sep 22, 2026
@github-actions github-actions Bot removed the update snapshots 🤖 Command that updates VRT snapshots on the pull request label Sep 22, 2026
@joshfarrant joshfarrant added update snapshots 🤖 Command that updates VRT snapshots on the pull request and removed update snapshots 🤖 Command that updates VRT snapshots on the pull request labels Sep 22, 2026
@github-actions
github-actions Bot temporarily deployed to storybook-preview-8442 September 22, 2026 16:01 Inactive
@github-actions github-actions Bot removed the update snapshots 🤖 Command that updates VRT snapshots on the pull request label Sep 22, 2026
@joshfarrant joshfarrant added the update snapshots 🤖 Command that updates VRT snapshots on the pull request label Sep 22, 2026
@github-actions
github-actions Bot temporarily deployed to storybook-preview-8442 September 22, 2026 16:12 Inactive
@github-actions github-actions Bot removed the update snapshots 🤖 Command that updates VRT snapshots on the pull request label Sep 22, 2026
@github-actions
github-actions Bot temporarily deployed to storybook-preview-8442 September 22, 2026 16:23 Inactive
@github-actions
github-actions Bot temporarily deployed to storybook-preview-8442 September 22, 2026 16:31 Inactive
joshfarrant and others added 4 commits September 23, 2026 09:01
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Restore existing visual baselines and limit wrapping coverage to natural word boundaries.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@joshfarrant
joshfarrant force-pushed the joshfarrant-fix-segmented-control-wrapping branch from b3d5e7b to 6402b0f Compare September 23, 2026 08:01
@github-actions github-actions Bot added the integration-tests: failing Changes in this PR cause breaking changes in gh/gh label Sep 23, 2026
@joshfarrant joshfarrant added the update snapshots 🤖 Command that updates VRT snapshots on the pull request label Sep 23, 2026
@github-actions
github-actions Bot temporarily deployed to storybook-preview-8442 September 23, 2026 08:13 Inactive
@github-actions github-actions Bot removed the update snapshots 🤖 Command that updates VRT snapshots on the pull request label Sep 23, 2026
Keep intrinsic multiline growth without allowing flex parents to stretch single-line controls.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@joshfarrant
joshfarrant force-pushed the joshfarrant-fix-segmented-control-wrapping branch from 41565d8 to 0db2543 Compare September 23, 2026 08:20
@joshfarrant joshfarrant added the update snapshots 🤖 Command that updates VRT snapshots on the pull request label Sep 23, 2026
@github-actions
github-actions Bot temporarily deployed to storybook-preview-8442 September 23, 2026 08:23 Inactive
@github-actions github-actions Bot removed the update snapshots 🤖 Command that updates VRT snapshots on the pull request label Sep 23, 2026
Verify computed wrapping styles and accessory labels remain unclipped and unsplit.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@joshfarrant

Copy link
Copy Markdown
Contributor Author

Final github-ui integration assessment for github/github-ui#34664 at 05637c8aa:

  • Primer Integration Changes, Projects, and VRT all passed.
  • CI failed only in @github-ui/issue-metadata:test. The original attempt failed two ProjectItemSectionFieldListTanStack cases; a failed-jobs retry reproduced the same settles a confirmed field clear when the response also contains unrelated GraphQL errors failure at line 683.
  • The same line-683 test already failed in the prior integration run (35755082152), before the final SegmentedControl package.
  • The strict locator sees both the visible Choose an option value and Choose an option, filter text box and list of items… in the live region. That announcement comes from the FilteredActionList changes introduced on Primer main by SelectPanel: Announce filter input name on initial focus #8413 (d4e30ed18), not from this PR.
  • This PR's source diff against origin/main contains only SegmentedControl source/stories/tests/snapshots and its changeset. packages/issue-metadata has no SegmentedControl usage, and the downstream VRT/Projects suites are green.

This is a real downstream test incompatibility with an unrelated Primer-main FilteredActionList change, not a SegmentedControl regression. The failed run and retry remain linked for follow-up; applying the repository-standard integration-tests: skipped manually disposition only for #8442. The PR remains draft.

@joshfarrant joshfarrant added integration-tests: skipped manually Changes in this PR do not require an integration test and removed integration-tests: failing Changes in this PR cause breaking changes in gh/gh labels Sep 23, 2026
@primer-integration

Copy link
Copy Markdown

Integration test results from github/github-ui PR:

Passed  Changes   Passed
Failed  CI   Failed
Passed  VRT   Passed
Passed  Projects   Passed

CI check runs linting, type checking, and unit tests. Check the workflow logs for specific failures.

Need help? If you believe this failure is unrelated to your changes, please reach out to the Primer team for assistance.

@joshfarrant
joshfarrant marked this pull request as ready for review September 23, 2026 11:39
@joshfarrant
joshfarrant requested a balanced review from Copilot September 23, 2026 14:14
@joshfarrant

Copy link
Copy Markdown
Contributor Author

Thanks for the review @liuliu-dev!

Heads up that I spotted some VRTs were showing some unintended changes so I've pushed a fix for that. No changes to existing VRTs now, the only VRT change is the addition of the new ones.

Just flagging for you in case you wanted to take another look before I merge

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟢 Approval recommended

The focused styling fix is well covered across sizes, variants, reflow, and unchanged single-line behavior.

Review effort: Balanced
Findings: None

Resolved since last review (1)

@liuliu-dev

Copy link
Copy Markdown
Contributor

@joshfarrant thanks for the heads up! Looks great! ✨

This branch was successfully deployed

2 active deployments
storybook-preview-8442 d7bfaa1e Deployed Sep 23, 2026 by github-actions[bot]
github-pages d7bfaa1e Deployed Sep 23, 2026 by joshfarrant via deploy-preview #33420
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

integration-tests: skipped manually Changes in this PR do not require an integration test

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants